package com.infisight.hudprojector.util;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.util.Log;

public class Utils {
	public static final String DAY_NIGHT_MODE="daynightmode";
	public static final String DEVIATION="deviationrecalculation";
	public static final String JAM="jamrecalculation";
	public static final String TRAFFIC="trafficbroadcast";
	public static final String CAMERA="camerabroadcast";
	public static final String SCREEN="screenon";
	public static final String THEME="theme";
	public static final String ISEMULATOR="isemulator";
	
	
	public static final String ACTIVITYINDEX="activityindex";
	
	public static final int SIMPLEHUDNAVIE=0;
	public static final int EMULATORNAVI=1;
	public static final int SIMPLEGPSNAVI=2;
	public static final int SIMPLEROUTENAVI=3;
	
	
	public static final boolean DAY_MODE=false;
	public static final boolean NIGHT_MODE=true;
	public static final boolean YES_MODE=true;
	public static final boolean NO_MODE=false;
	public static final boolean OPEN_MODE=true;
	public static final boolean CLOSE_MODE=false;

	/**
	 * 以秒换算小时和分钟
	 * @return
	 */
	public static String getHourMinuteBySecond(int second)
	{
		int h = 0;
		  int d = 0;
		  int s = 0;
		  int temp = second%3600;
		       if(second>3600){
		         h= second/3600;
		              if(temp!=0){
		         if(temp>60){
		         d = temp/60;
		      if(temp%60!=0){
		         s = temp%60;
		      }
		      }else{
		         s = temp;
		      }
		     }
		    }else{
		        d = second/60;
		     if(second%60!=0){
		        s = second%60;
		     }
		    }
		   String strformat = String.format("%02d:%02d:%02d", h,d,s);
		   return strformat;
	}
	/**
	 * 换算千米
	 * @return
	 */
	public static String getKileMeters(int mile)
	{
		String dataret = "0.0";
		String unitret = "千米";
		dataret = new DecimalFormat("0.000").format(mile*0.001);
		return dataret+unitret;
	}
	/**
	 * 
	 * @param second 还剩余的秒数 
	 * @return
	 */
	public static String getArriveTime(int second)
	{
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.SECOND, second);
		Log.d("Utils", "second:"+second);
		SimpleDateFormat FORMAT2 = new SimpleDateFormat("MM-dd HH:mm:ss");
		return FORMAT2.format(calendar.getTime());
	}

}
